package test.byteoper;

/**
 * Created by linshuo on 2018/2/9.
 */
public class ByteUtil {
    public static void main(String[] args) {
        System.out.println(toHexString(-25, 4));
    }

    /** 转为十六进制字符串
     * @param num
     * @param byteSize
     * @return
     */
    private static String toHexString(long num, int byteSize) {
        String rawStr = Long.toHexString(num).substring(Long.SIZE / 4 - 2 * byteSize);
        return "0x"+rawStr.toUpperCase();
    }
}
